home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD v2.1 / Amiga Developer CD v2.1.iso / CD32 / CD32_Support / examples / MaxSpeed.c < prev    next >
C/C++ Source or Header  |  1993-10-17  |  8KB  |  173 lines

  1.  
  2. /*
  3.  
  4.     The AmigaCD has an added feature that allows the CD-ROM drive to
  5. perform in a double-speed mode of operation (300Kb/s) (150 frames/s).  If
  6. you wish to have the drive operate in double-speed, you need to do two
  7. things.  The first thing is very important.  You need to put your data as
  8. close to the outermost tracks as possible.  Double-speed works best when
  9. your data is on the outer tracks.  Carl Sassenrath's ISO tools give you the
  10. ability to pad the beginning of the disk allowing you to place your data as
  11. far out as possible.  The drive will not prohibit you from using
  12. double-speed on the inner tracks of the disk, but you should really use
  13. double-speed on the outer tracks for best results.  The second thing you
  14. need to do is tell the drive to do double-speed.  This is done by the
  15. using the following examples.  Normally, the only command that you may want
  16. to configure for double-speed is the CD_READ command; however, if you are
  17. doing CDXL, you may want to configure the CD_READXL command for
  18. double-speed.
  19.  
  20.     The MaxReadSpeed() function is used to configure the CD_READ command to
  21. the maximum speed the drive is capable of.  The SetReadXLSpeed() function
  22. is used to configure the CD_READXL command to a desired speed.  If the only
  23. thing you wish to use double-speed for is an XL sequence, then you only
  24. need to use the SetReadXLSpeed() example.  You do not NEED to configure the
  25. CD_READ command to do double-speed as well.  Just make sure that you XL
  26. sequence is on the outer tracks of the disk.
  27.  
  28.     We hope this will help you in getting the desired performance from your
  29. application.
  30.  
  31.  
  32.  
  33. */
  34.  
  35.  
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40.  
  41. #include <exec/io.h>
  42. #include <exec/memory.h>
  43. #include <utility/tagitem.h>
  44. #include <devices/cd.h>
  45.  
  46. #include <clib/exec_protos.h>
  47. #include <pragmas/exec_pragmas.h>
  48.  
  49. extern struct SysBase *SysBase;
  50.  
  51. struct IOStdReq *IOR;
  52. struct MsgPort  *Port;
  53.  
  54. struct CDInfo    CDInfo;
  55. struct TagItem   ConfigList[] = {
  56.  
  57.     { 0,       0 },
  58.     { TAG_END, 0 }
  59.     };
  60.  
  61.  
  62. /***************************************************************************
  63.  *                                                                         *
  64.  *  int MaxReadSpeed(void) -- Set the speed of the READ command to the     *
  65.  *                            maximum that the drive can handle.           *
  66.  *                                                                         *
  67.  ***************************************************************************/
  68.  
  69. int MaxReadSpeed(void) {
  70.  
  71. int success = 0;
  72.  
  73.     if (Port = CreateMsgPort()) {                                           /* Create reply port                */
  74.  
  75.         if (IOR = CreateIORequest(Port, sizeof(struct IOStdReq))) {         /* Create IORequest                 */
  76.  
  77.             if (!OpenDevice("cd.device", 0L, IOR, 0L)) {                    /* Open cd.device                   */
  78.  
  79.                 IOR->io_Command = CD_INFO;                                  /* Get maximum drive speed          */
  80.                 IOR->io_Data    = (APTR)&CDInfo;
  81.                 IOR->io_Offset  = 0;
  82.                 IOR->io_Length  = sizeof(struct CDInfo);
  83.                 DoIO(IOR);
  84.  
  85.                 if (!IOR->io_Error) {                                       /* Success?                         */
  86.  
  87.                     ConfigList[0].ti_Tag = TAGCD_READSPEED;                 /* Modify TagList                   */
  88.                     ConfigList[0].ti_Data = CDInfo.MaxSpeed;
  89.  
  90.                     IOR->io_Command = CD_CONFIG;                            /* Configure drive to maximum speed */
  91.                     IOR->io_Data    = (APTR)&ConfigList;
  92.                     IOR->io_Length  = 0;
  93.                     DoIO(IOR);
  94.  
  95.                     if (!IOR->io_Error) success = 1;                        /* Report success                   */
  96.                     }
  97.  
  98.                 CloseDevice(IOR);                                           /* Close cd.device                  */
  99.                 }
  100.  
  101.             DeleteIORequest(IOR);                                           /* Delete IORequest                 */
  102.             }
  103.  
  104.         DeleteMsgPort(Port);                                                /* Delete reply port                */
  105.         }
  106.  
  107.     return(success);                                                        /* Return success                   */
  108.     }
  109.  
  110.  
  111.  
  112.  
  113. /***************************************************************************
  114.  *                                                                         *
  115.  *  int SetReadSpeed(int Speed) -- Set the speed of the READXL command to  *
  116.  *                                 the desired frame rate.                 *
  117.  *                                                                         *
  118.  ***************************************************************************/
  119.  
  120. int SetReadXLSpeed(int Speed) {
  121.  
  122. int success = 0;
  123.  
  124.     if (Port = CreateMsgPort()) {                                           /* Create reply port                */
  125.                                                                                                                   
  126.         if (IOR = CreateIORequest(Port, sizeof(struct IOStdReq))) {         /* Create IORequest                 */
  127.                                                                                                                   
  128.             if (!OpenDevice("cd.device", 0L, IOR, 0L)) {                    /* Open cd.device                   */
  129.  
  130.                 ConfigList[0].ti_Tag = TAGCD_READXLSPEED;                   /* Modify TagList                   */
  131.                 ConfigList[0].ti_Data = Speed;
  132.  
  133.                 IOR->io_Command = CD_CONFIG;                                /* Configure drive to desired speed */
  134.                 IOR->io_Data    = (APTR)&ConfigList;
  135.                 IOR->io_Length  = 0;
  136.                 DoIO(IOR);
  137.  
  138.                 if (!IOR->io_Error) success = 1;                            /* Report success                   */
  139.                                                                                                                   
  140.                 CloseDevice(IOR);                                                                                 
  141.                 }                                                           /* Close cd.device                  */
  142.                                                                                                                   
  143.             DeleteIORequest(IOR);                                                                                 
  144.             }                                                               /* Delete IORequest                 */
  145.                                                                                                                   
  146.         DeleteMsgPort(Port);                                                                                      
  147.         }                                                                   /* Delete reply port                */
  148.                                                                                                                   
  149.     return(success);                                                                                              
  150.     }                                                                       /* Return success                   */
  151.  
  152.  
  153.  
  154.  
  155.  
  156. /***************************************************************************
  157.  *                                                                         *
  158.  *  Try setting the READ speed to the maximum the drive can handle and try *
  159.  *  setting the speed of the READXL command to 300Kb/s.                    *
  160.  *                                                                         *
  161.  ***************************************************************************/
  162.  
  163. void main (int argc, char **argv) {
  164.  
  165.     if (MaxReadSpeed()) printf("Read commands are at maximum speed\n");     /* Set READ commands to max speed   */
  166.  
  167.     if (!SetReadXLSpeed(150)) printf("Drive can't support double-speed\n"); /* Try to set READXL frame rate to  */
  168.                                                                             /* 150 frames/second (300Kb/s)      */
  169.     }
  170.  
  171.  
  172.  
  173.